<?php
namespace jiaojie\sort\quicksort;
use jiaojie\sort\quicksort as quicksort;

class demo {
    public static function sort(array $arr) {
        $num = count($arr);
        if($num <= 1) {
            return $arr;
        }
        $cursor = array($arr[0]);
        $pre = array();
        $aft = array();
        foreach($arr as $k => $v) {
            if($k == 0) {
                continue;
            } 
            if($v >= $arr[0]) {
                $aft[] = $v;
            } elseif($v < $arr[0]) {
                $pre[] = $v;
            }
        }
        $pre = self::sort($pre);
        $aft = self::sort($aft);

        return array_merge($pre, $cursor, $aft);
    }
}

$arr = [];
for($i = 0; $i < 100; $i++) {
    $arr[] = rand(1, 10);
}
print_r($arr);

$sort = quicksort\demo::sort($arr);
print_r($sort);
